package com.candy.demo4;

import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

public class PropertiesDemo {
    public static void main(String[] args) throws Exception{
        //类的加载器
        InputStream in = PropertiesDemo.class.getClassLoader().getResourceAsStream("database.properties");
        System.out.println(in);
        Properties pro = new Properties();
        pro.load(in);
        //获取集合中的键值对
        String driverClass = pro.getProperty("DirverClass");
        String url = pro.getProperty("url");
        String username = pro.getProperty("username");
        String password = pro.getProperty("password");
        Class.forName(driverClass);
        Connection conn = DriverManager.getConnection(url,username,password);
        System.out.println(conn);

    }
}
